home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / NRPAS13 / CHINT.DEM < prev    next >
Text File  |  1991-04-29  |  1KB  |  54 lines

  1. PROGRAM d5r6(input,output);
  2. (* driver for routine CHINT *)
  3. LABEL 10,99;
  4. CONST
  5.    nval=40;
  6.    pio2=1.5707963;
  7. TYPE
  8.    glcarray=ARRAY [1..nval] OF real;
  9. VAR
  10.    a,b,x : real;
  11.    i,mval : integer;
  12.    c,cint : glcarray;
  13.  
  14. FUNCTION func(x: real): real;
  15. BEGIN
  16.    func := sqr(x)*(sqr(x)-2.0)*sin(x)
  17. END;
  18.  
  19. FUNCTION fint(x: real): real;
  20. BEGIN
  21.    fint := 4.0*x*(sqr(x)-7.0)*sin(x)
  22.       -(sqr(sqr(x))-14.0*sqr(x)+28.0)*cos(x)
  23. END;
  24.  
  25. (*$I MODFILE.PAS *)
  26. (*$I CHEBFT.PAS *)
  27.  
  28. (*$I CHEBEV.PAS *)
  29.  
  30. (*$I CHINT.PAS *)
  31.  
  32. BEGIN
  33.    a := -pio2;
  34.    b := pio2;
  35.    chebft(a,b,c,nval);
  36. (* test integral *)
  37. 10:   writeln;
  38.    writeln('How many terms in Chebyshev evaluation?');
  39.    write('Enter n between 6 and ',nval:2,
  40.          '. (n := 0 to end).  ');
  41.    readln(mval);
  42.    IF ((mval <= 0) OR (mval > nval)) THEN GOTO 99;
  43.    chint(a,b,c,cint,mval);
  44.    writeln;
  45.    writeln('x':9,'actual':14,'Cheby. integ.':16);
  46.    FOR i := -8 to 8 DO BEGIN
  47.       x := i*pio2/10.0;
  48.       writeln(x:12:6,fint(x)-fint(-pio2):12:6,
  49.             chebev(a,b,cint,mval,x):12:6)
  50.    END;
  51.    GOTO 10;
  52. 99:
  53. END.
  54.